<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			div{
				width: 100px;
				height: 100px;
				border: 1px solid red;
				margin-bottom: 10px;
			}
		</style>
		<script type="text/javascript">
			window.onload = function() {
				var my_btn = document.getElementById("btn");

				my_btn.onclick = function() {
					//通过class值来获取元素            有兼容问题
					var my_div = document.getElementsByClassName("haha");
					console.log(my_div);
				}
			}
		</script>
	</head>

	<body>
		<input type="button" id="btn" value="提交" />
		<div id="box">1</div>
		<div class="haha">2</div>
		<div class="haha">3</div>
		<div class="haha">4</div>
	</body>

</html>